feat: resolve same-file compose extends by flattening inheritance#33
Merged
Conversation
A non-dict service value (e.g. `services: {web: null}`) crashed with an
uncaught TypeError (exit 1) instead of a clean UnsupportedComposeError
(exit 2). Root-cause fix in two places: validate() now guards non-dict
service values before iterating them, and resolve_extends() defers to
validate() instead of crashing when a service's extends base is not a
mapping.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Support the common form of compose
extends— a service inheriting another service's config within the same document. A new pure modulecompose2pod/extends.pyexposesresolve_extends(compose) -> composethat flattens every service'sextendsaway (transitive, cycle-checked, per-key merge) beforevalidate()runs, so the rest of the pipeline never seesextends. Cross-filefile:extends is refused loudly, keeping compose2pod's single-document input model intact.Design:
planning/changes/2026-07-11.01-extends.md. This is the largest Bucket B item from the coverage audit.What's supported
extends: {service: <name>});servicemust name a service in the same document. Transitive, with cycle detection.cli.py(resolve_extends→validate→emit_script); also exported as public API for library callers.file:, bare-stringextends, unknownextendskeys, non-stringservice, unknown referenced service, and incompatible-form merges are each refused with a distinctUnsupportedComposeError.Merge semantics (per-key category, matching the spec for the supported subset)
environment,labels,annotations,extra_hosts,ulimits,healthcheck,depends_on. List-formenvironment/depends_onare normalized to mappings first.cap_add,cap_drop,security_opt,devices,group_add,secrets,configs,volumes,tmpfs,env_file. Scalartmpfs/env_filenormalized to a one-element list first.command/entrypoint(argv, replaced not concatenated) and unknown keys (whichvalidate()then rejects).Where a faithful merge is impossible (a mapping-merge key that is neither a mapping nor a list-form
environment/depends_on, or a concat key that is neither a list nor a scalar string), resolution refuses loudly rather than guessing.Documented divergences
environment/depends_onaccept list form for the mapping-merge; other mapping-merge keys in list form on a merged side are refused (not silently coerced).volumesare concatenated rather than merged by target path (podman resolves duplicate mounts).Robustness
A whole-branch review found that a service extending a non-dict base (e.g. a null service body) crashed raw. Fixed at the root:
parsing.validate()now rejects a non-dict service value ("service X must be a mapping"), andresolve_extendsdefers such a base to validation instead of crashing — both paths now return a clean exit 2 with no traceback.Testing
just test-ciat 100% coverage (293 tests),just lint-ciclean,just check-planningOK.tests/test_extends.pycovers each merge category, list/scalar normalization, transitive + diamond resolution, cycle detection, and every refusal;tests/test_cli.pyproves the end-to-end pipeline (a merged doc emits correctly; afile:extends and a non-dict base each return a clean error).architecture/supported-subset.mdgains an## Extendssection.